package com.devunion.salon.persistence;

import javax.persistence.*;

/**
 * CREATE TABLE `transaction` (
 * `id` int(11) NOT NULL auto_increment,
 * `created_dt` datetime default NULL,
 * `customer_id` int(11) NOT NULL default '0',
 * `service_id` int(11) default NULL,
 * `product_id` int(11) default NULL,
 * `employee_id` int(11) default NULL,
 * `payment` varchar(50) default '''Cash''',
 * `location_id` int(11) default NULL,
 * `discount` decimal(10,3) default NULL,
 * `price` decimal(10,3) default NULL,
 * `code` varchar(10) NOT NULL,
 * `sn` varchar(20) default NULL,
 * `tax` decimal(10,3) default '0.000',
 * `remainder` decimal(10,3) default '0.000',
 * `change_f` decimal(10,3) default '0.000',
 * PRIMARY KEY  (`id`)
 * ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=49 ;
 *
 * @author Viktar Liaskovich
 */
@Entity
@Table(name = "transaction")
public class Transaction extends BasePersistentObject {
    @Column(name = "number", nullable = true)
    private String number;

    @ManyToOne()
    private Service service;

    @ManyToOne()
    private Product product;

    @OneToOne(cascade = {CascadeType.ALL})
    private GiftCard giftCard;

    @Column(name = "quantity", nullable = false)
    private Integer quantity;

    @ManyToOne()
    private Employee employee;

    public Service getService() {
        return service;
    }

    public void setService(Service service) {
        this.service = service;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public GiftCard getGiftCard() {
        return giftCard;
    }

    public void setGiftCard(GiftCard giftCard) {
        this.giftCard = giftCard;
    }
}
